package com.example.coreshopapp.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

public class OrderingUtils {

    static public double toFixedTwo(BigDecimal price) {
        return price.setScale(2, RoundingMode.HALF_UP).doubleValue();
    }

    static public int calculateNum(BigDecimal price) {
        return price.setScale(2, RoundingMode.HALF_UP).intValue();
    }

    // 保留两位小数
    static public double toFixed(double price) {
        return BigDecimal.valueOf(price).setScale(2, RoundingMode.HALF_UP).doubleValue();
    }
}
